package main

import (
	"encoding/json"
	"github.com/tealeg/xlsx"
	"net/url"
	"os"
)

func LoadXlsSheet() *xlsx.Sheet {
	XlFile, _ := xlsx.OpenFile(ExcelFileName)
	return XlFile.Sheets[0]
}
func GetProposalNo(Url string) string {
	parsedURL, err := url.Parse(Url)
	if err != nil {
		println("Error parsing URL:", err)
		return ""
	}
	queryParams := parsedURL.Query()
	parsedURL, err = url.Parse(queryParams.Get("split"))
	return parsedURL.Query().Get("proposalno")
}
func CreateFolder() {
	folder := "sign/"
	err := os.RemoveAll(folder)
	if err != nil {
		println("移除sign文件夹失败" + err.Error())
		return
	}
	err = os.Mkdir(folder, os.ModePerm)
	if err != nil {
		println("创建文件夹时出错:", err)
		return
	}
}
func ParseBean[T any](data []byte) (T, error) {
	var t T
	err := json.Unmarshal(data, &t)
	if err != nil {
		println("json解析失败" + err.Error())
		return t, err
	}
	return t, nil
}
